% allows you to visually check how well the eye tracking performed for a
% given movie.
% 
% input: filename of the eye tracking data (result of batchTrackEye.m
%
% no output - just opens a figure and plays the eye movie with the tracking
% overlaid

function checkEyeTracking(trackingFilename,mov,center,radius)

if nargin==1
    load(trackingFilename)
    v = VideoReader(movname);
    mov = read(v);
    mov = mov(:,:,1,:);
    mov = reshape(mov,size(mov,1),size(mov,2),size(mov,4));
end
plotfig = figure;

%% do interpolation if want:
intCent = center;
intRad = radius;
vi = find(~isnan(center(:,1)));
blanki = find(isnan(center(:,1)));
radius = radius(:,1);
try
    intCent(blanki,1) = interp1(vi,center(vi,1),blanki);%,'makima');
    intCent(blanki,2) = interp1(vi,center(vi,2),blanki);%,'makima');
    intRad(blanki) = interp1(vi,radius(vi),blanki);%,'makima');
catch
    disp('failed to do interpolation')
end
for n = 1:size(mov,3)
    imagesc(mov(:,:,n));
    viscircles(intCent(n,:),intRad(n),'EdgeColor','r');
    viscircles(center(n,:),radius(n),'EdgeColor','b');
    title(n)
    pause(.03)
end
